import torch
from torch.nn.utils.rnn import pad_sequence

# 假设这是你的 list，里面每个元素是不同尺寸的 Tensor
tensor_list = [
    torch.randn(384, 121, 6),
    torch.randn(361, 121, 6),
    torch.randn(218, 121, 6),
    torch.randn(881, 121, 6),
    torch.randn(10, 238, 6),
    torch.randn(699, 121, 6),
    torch.randn(11, 241, 6),
    torch.randn(658, 121, 6)
]

# 1. 将每个 NumPy 数组转换为 PyTorch Tensor，并且确保是 list of tensors
tensor_list = [t for t in tensor_list]

# 2. 使用 pad_sequence 对第1个维度（m）进行填充
padded_tensors = pad_sequence(tensor_list, batch_first=True)

# 打印填充后的形状
print(f"填充后的形状: {padded_tensors.shape}")
